﻿using System;
using System.Collections.Generic;
using Budgetsch.Web.EntityModel;
using Budgetsch.Web.Services;
using GalaSoft.MvvmLight;

namespace Budgetsch.ViewModels.Costs
{
    public abstract class CostDetailVMBase : ViewModelBase
    {
        protected readonly BudgetschDomainContext m_context;

        public IEnumerable<CostCategory> Categories { get; set; }
        

        private Cost m_cost;
        public const string NewCostPropertyName = "Cost";
        public Cost Cost
        {
            get
            {
                return m_cost;
            }

            set
            {
                if (m_cost == value)
                {
                    return;
                }

                m_cost = value;
                RaisePropertyChanged(() => Cost);
            }
        }

        protected CostDetailVMBase(BudgetschDomainContext context_)
        {
            m_context = context_;
            m_context.Load(m_context.GetCostCategoriesWithItemsQuery());
            Categories = m_context.CostCategories;
        }

        public abstract void Commit();
    }
}